package com.ukao.cashregister.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.BatchlTabBean;

import java.util.List;

/**
 * Created by ukaodev on 2017/6/14.
 */

public class BatchDialogAdapter extends CommonAdapter<BatchlTabBean.ListBean> {




    public BatchDialogAdapter(Context context, List<BatchlTabBean.ListBean> datas) {
        super(context, datas, R.layout.adapter_dialog_batch);
    }



    @Override
    public void convert(final  ViewHolder holder, BatchlTabBean.ListBean item) {

        TextView code = holder.getView(R.id.code);
        TextView productCnt = holder.getView(R.id.productCnt);
        ImageView selectCheckbox = holder.getView(R.id.selectCheckbox);
        code.setText(item.getCode());
        productCnt.setText((item.getProductCnt()+item.getAnnexCnt())+"");
        if(item.isCheck()){
            Drawable drawable= mContext.getResources().getDrawable(R.drawable.check_box_check);
            selectCheckbox.setImageDrawable(drawable);
            holder.itemView.setBackgroundResource(R.color.back_blue);
        }else{
            Drawable drawable=  mContext.getResources().getDrawable(R.drawable.check_box_normal);
            /// 这一步必须要做,否则不会显示.
            selectCheckbox.setImageDrawable(drawable);
            holder.itemView.setBackgroundResource(R.color.white);
        }

    }

}
